Class java.awt.Event
All Packages Class Hierarchy This Package Previous Next Index
Class java.awt.Event
Object
|
+----java.awt.Event
- public class Event
- extends Object
- implements Serializable
Event
is a platform-independent class that
encapsulates events from the platform's Graphical User
Interface in the Java 1.0 event model. In Java 1.1
and later versions, the Event
class is maintained
only for backwards compatibilty. The information in this
class description is provided to assist programmers in
converting Java 1.0 programs to the new event model.
In the Java 1.0 event model, an event contains an
id
field
that indicates what type of event it is and which other
Event
variables are relevant for the event.
For keyboard events, key
contains a value indicating which key was activated, and
modifiers
contains the
modifiers for that event. For the KEY_PRESS and KEY_RELEASE
event ids, the value of key
is the unicode
character code for the key. For KEY_ACTION and
KEY_ACTION_RELEASE, the value of key
is
one of the defined action-key identifiers in the
Event
class (PGUP
,
PGDN
, F1
, F2
, etc).
- Version:
- 1.58 07/01/98
- Author:
- Sami Shaio
- Since:
- JDK1.0
-
ACTION_EVENT
- This event indicates that the user wants some action to occur.
-
ALT_MASK
-
This flag indicates that the Alt key was down when
the event occurred.
-
BACK_SPACE
- The BackSpace key.
-
CAPS_LOCK
- The Caps Lock key, a non-ASCII action key.
-
CTRL_MASK
- This flag indicates that the Control key was down when the event
occurred.
-
DELETE
- The Delete key.
-
DOWN
- The Down Arrow key, a non-ASCII action key.
-
END
-
The End key, a non-ASCII action key.
-
ENTER
- The Enter key.
-
ESCAPE
- The Escape key.
-
F1
- The F1 function key, a non-ASCII action key.
-
F10
- The F10 function key, a non-ASCII action key.
-
F11
- The F11 function key, a non-ASCII action key.
-
F12
- The F12 function key, a non-ASCII action key.
-
F2
- The F2 function key, a non-ASCII action key.
-
F3
- The F3 function key, a non-ASCII action key.
-
F4
- The F4 function key, a non-ASCII action key.
-
F5
- The F5 function key, a non-ASCII action key.
-
F6
- The F6 function key, a non-ASCII action key.
-
F7
- The F7 function key, a non-ASCII action key.
-
F8
- The F8 function key, a non-ASCII action key.
-
F9
- The F9 function key, a non-ASCII action key.
-
GOT_FOCUS
- A component gained the focus.
-
HOME
-
The Home key, a non-ASCII action key.
-
INSERT
- The Insert key, a non-ASCII action key.
-
KEY_ACTION
-
The user has pressed a non-ASCII action key.
-
KEY_ACTION_RELEASE
-
The user has released a non-ASCII action key.
-
KEY_PRESS
- The user has pressed a normal key.
-
KEY_RELEASE
- The user has released a normal key.
-
LEFT
- The Left Arrow key, a non-ASCII action key.
-
LIST_DESELECT
- An item in a list has been deselected.
-
LIST_SELECT
- An item in a list has been selected.
-
LOAD_FILE
- A file loading event.
-
LOST_FOCUS
- A component lost the focus.
-
META_MASK
-
This flag indicates that the Meta key was down when the event
occurred.
-
MOUSE_DOWN
- The user has pressed the mouse button.
-
MOUSE_DRAG
-
The user has moved the mouse with a button pressed.
-
MOUSE_ENTER
- The mouse has entered a component.
-
MOUSE_EXIT
- The mouse has exited a component.
-
MOUSE_MOVE
- The mouse has moved with no button pressed.
-
MOUSE_UP
- The user has released the mouse button.
-
NUM_LOCK
- The Num Lock key, a non-ASCII action key.
-
PAUSE
- The Pause key, a non-ASCII action key.
-
PGDN
- The Page Down key, a non-ASCII action key.
-
PGUP
- The Page Up key, a non-ASCII action key.
-
PRINT_SCREEN
- The Print Screen key, a non-ASCII action key.
-
RIGHT
- The Right Arrow key, a non-ASCII action key.
-
SAVE_FILE
- A file saving event.
-
SCROLL_ABSOLUTE
- The user has moved the bubble (thumb) in a scroll bar,
moving to an "absolute" position, rather than to
an offset from the last postion.
-
SCROLL_BEGIN
- The scroll begin event.
-
SCROLL_END
- The scroll end event.
-
SCROLL_LINE_DOWN
- The user has activated the line down
area of a scroll bar.
-
SCROLL_LINE_UP
-
The user has activated the line up
area of a scroll bar.
-
SCROLL_LOCK
- The Scroll Lock key, a non-ASCII action key.
-
SCROLL_PAGE_DOWN
- The user has activated the page down
area of a scroll bar.
-
SCROLL_PAGE_UP
- The user has activated the page up
area of a scroll bar.
-
SHIFT_MASK
- This flag indicates that the Shift key was down when the event
occurred.
-
TAB
- The Tab key.
-
UP
- The Up Arrow key, a non-ASCII action key.
-
WINDOW_DEICONIFY
-
The user has asked the window manager to de-iconify the window.
-
WINDOW_DESTROY
- The user has asked the window manager to kill the window.
-
WINDOW_EXPOSE
- The user has asked the window manager to expose the window.
-
WINDOW_ICONIFY
-
The user has asked the window manager to iconify the window.
-
WINDOW_MOVED
- The user has asked the window manager to move the window.
-
arg
- An arbitrary argument of the event.
-
clickCount
- For
MOUSE_DOWN
events, this field indicates the
number of consecutive clicks.
-
evt
- The next event.
-
id
- Indicates which type of event the event is, and which
other
Event
variables are relevant for the event.
-
key
-
The key code of the key that was pressed in a keyboard event.
-
modifiers
-
The state of the modifier keys.
-
target
- The target component.
-
when
- The time stamp.
-
x
-
The x coordinate of the event.
-
y
-
The y coordinate of the event.
-
java.awt.Event(Object, long, int, int, int, int, int, Object)
- Creates an instance of
Event
with the specified target
component, time stamp, event type, x and y
coordinates, keyboard key, state of the modifier keys, and
argument.
-
java.awt.Event(Object, long, int, int, int, int, int)
- Creates an instance of
Event
, with the specified target
component, time stamp, event type, x and y
coordinates, keyboard key, state of the modifier keys, and an
argument set to null
.
-
java.awt.Event(Object, int, Object)
- Creates an instance of
Event
with the specified
target component, event type, and argument.
-
controlDown()
- Checks if the Control key is down.
-
metaDown()
- Checks if the Meta key is down.
-
paramString()
- Returns the parameter string representing this event.
-
shiftDown()
- Checks if the Shift key is down.
-
toString()
- Returns a representation of this event's values as a string.
-
translate(int, int)
-
Translates this event so that its x and y
coordinates are increased by dx and dy,
respectively.
ACTION_EVENT
public static final int ACTION_EVENT
- This event indicates that the user wants some action to occur.
- Since:
JDK1.0
ALT_MASK
public static final int ALT_MASK
- This flag indicates that the Alt key was down when
the event occurred. For mouse events, this flag indicates that the
middle mouse button was pressed or released.
- Since:
JDK1.0
BACK_SPACE
public static final int BACK_SPACE
- The BackSpace key.
- Since:
JDK1.0
CAPS_LOCK
public static final int CAPS_LOCK
- The Caps Lock key, a non-ASCII action key.
- Since:
JDK1.0
CTRL_MASK
public static final int CTRL_MASK
- This flag indicates that the Control key was down when the event
occurred.
- Since:
JDK1.0
DELETE
public static final int DELETE
- The Delete key.
- Since:
JDK1.0
DOWN
public static final int DOWN
- The Down Arrow key, a non-ASCII action key.
- Since:
JDK1.0
END
public static final int END
- The End key, a non-ASCII action key.
- Since:
JDK1.0
ENTER
public static final int ENTER
- The Enter key.
- Since:
JDK1.0
ESCAPE
public static final int ESCAPE
- The Escape key.
- Since:
JDK1.0
F1
public static final int F1
- The F1 function key, a non-ASCII action key.
- Since:
JDK1.0
F10
public static final int F10
- The F10 function key, a non-ASCII action key.
- Since:
JDK1.0
F11
public static final int F11
- The F11 function key, a non-ASCII action key.
- Since:
JDK1.0
F12
public static final int F12
- The F12 function key, a non-ASCII action key.
- Since:
JDK1.0
F2
public static final int F2
- The F2 function key, a non-ASCII action key.
- Since:
JDK1.0
F3
public static final int F3
- The F3 function key, a non-ASCII action key.
- Since:
JDK1.0
F4
public static final int F4
- The F4 function key, a non-ASCII action key.
- Since:
JDK1.0
F5
public static final int F5
- The F5 function key, a non-ASCII action key.
- Since:
JDK1.0
F6
public static final int F6
- The F6 function key, a non-ASCII action key.
- Since:
JDK1.0
F7
public static final int F7
- The F7 function key, a non-ASCII action key.
- Since:
JDK1.0
F8
public static final int F8
- The F8 function key, a non-ASCII action key.
- Since:
JDK1.0
F9
public static final int F9
- The F9 function key, a non-ASCII action key.
- Since:
JDK1.0
GOT_FOCUS
public static final int GOT_FOCUS
- A component gained the focus.
- Since:
JDK1.0
HOME
public static final int HOME
- The Home key, a non-ASCII action key.
- Since:
JDK1.0
INSERT
public static final int INSERT
- The Insert key, a non-ASCII action key.
- Since:
JDK1.0
KEY_ACTION
public static final int KEY_ACTION
- The user has pressed a non-ASCII action key.
The
key
field contains a value that indicates
that the event occurred on one of the action keys, which
comprise the 12 function keys, the arrow (cursor) keys,
Page Up, Page Down, Home, End, Print Screen, Scroll Lock,
Caps Lock, Num Lock, Pause, and Insert.
- Since:
JDK1.0
KEY_ACTION_RELEASE
public static final int KEY_ACTION_RELEASE
- The user has released a non-ASCII action key.
The
key
field contains a value that indicates
that the event occurred on one of the action keys, which
comprise the 12 function keys, the arrow (cursor) keys,
Page Up, Page Down, Home, End, Print Screen, Scroll Lock,
Caps Lock, Num Lock, Pause, and Insert.
- Since:
JDK1.0
KEY_PRESS
public static final int KEY_PRESS
- The user has pressed a normal key.
- Since:
JDK1.0
KEY_RELEASE
public static final int KEY_RELEASE
- The user has released a normal key.
- Since:
JDK1.0
LEFT
public static final int LEFT
- The Left Arrow key, a non-ASCII action key.
- Since:
JDK1.0
LIST_DESELECT
public static final int LIST_DESELECT
- An item in a list has been deselected.
- Since:
JDK1.0
LIST_SELECT
public static final int LIST_SELECT
- An item in a list has been selected.
- Since:
JDK1.0
LOAD_FILE
public static final int LOAD_FILE
- A file loading event.
- Since:
JDK1.0
LOST_FOCUS
public static final int LOST_FOCUS
- A component lost the focus.
- Since:
JDK1.0
META_MASK
public static final int META_MASK
- This flag indicates that the Meta key was down when the event
occurred. For mouse events, this flag indicates that the right
button was pressed or released.
- Since:
JDK1.0
MOUSE_DOWN
public static final int MOUSE_DOWN
- The user has pressed the mouse button. The
ALT_MASK
flag indicates that the middle button has been pressed.
The META_MASK
flag indicates that the
right button has been pressed.
- Since:
JDK1.0
- See Also:
- ALT_MASK, META_MASK
MOUSE_DRAG
public static final int MOUSE_DRAG
- The user has moved the mouse with a button pressed. The
ALT_MASK
flag indicates that the middle
button is being pressed. The META_MASK
flag indicates
that the right button is being pressed.
- Since:
JDK1.0
- See Also:
- ALT_MASK, META_MASK
MOUSE_ENTER
public static final int MOUSE_ENTER
- The mouse has entered a component.
- Since:
JDK1.0
MOUSE_EXIT
public static final int MOUSE_EXIT
- The mouse has exited a component.
- Since:
JDK1.0
MOUSE_MOVE
public static final int MOUSE_MOVE
- The mouse has moved with no button pressed.
- Since:
JDK1.0
MOUSE_UP
public static final int MOUSE_UP
- The user has released the mouse button. The
ALT_MASK
flag indicates that the middle button has been released.
The META_MASK
flag indicates that the
right button has been released.
- Since:
JDK1.0
- See Also:
- ALT_MASK, META_MASK
NUM_LOCK
public static final int NUM_LOCK
- The Num Lock key, a non-ASCII action key.
- Since:
JDK1.0
PAUSE
public static final int PAUSE
- The Pause key, a non-ASCII action key.
- Since:
JDK1.0
PGDN
public static final int PGDN
- The Page Down key, a non-ASCII action key.
- Since:
JDK1.0
PGUP
public static final int PGUP
- The Page Up key, a non-ASCII action key.
- Since:
JDK1.0
PRINT_SCREEN
public static final int PRINT_SCREEN
- The Print Screen key, a non-ASCII action key.
- Since:
JDK1.0
RIGHT
public static final int RIGHT
- The Right Arrow key, a non-ASCII action key.
- Since:
JDK1.0
SAVE_FILE
public static final int SAVE_FILE
- A file saving event.
- Since:
JDK1.0
SCROLL_ABSOLUTE
public static final int SCROLL_ABSOLUTE
- The user has moved the bubble (thumb) in a scroll bar,
moving to an "absolute" position, rather than to
an offset from the last postion.
- Since:
JDK1.0
SCROLL_BEGIN
public static final int SCROLL_BEGIN
- The scroll begin event.
- Since:
JDK1.0
SCROLL_END
public static final int SCROLL_END
- The scroll end event.
- Since:
JDK1.0
SCROLL_LINE_DOWN
public static final int SCROLL_LINE_DOWN
- The user has activated the line down
area of a scroll bar.
- Since:
JDK1.0
SCROLL_LINE_UP
public static final int SCROLL_LINE_UP
- The user has activated the line up
area of a scroll bar.
- Since:
JDK1.0
SCROLL_LOCK
public static final int SCROLL_LOCK
- The Scroll Lock key, a non-ASCII action key.
- Since:
JDK1.0
SCROLL_PAGE_DOWN
public static final int SCROLL_PAGE_DOWN
- The user has activated the page down
area of a scroll bar.
- Since:
JDK1.0
SCROLL_PAGE_UP
public static final int SCROLL_PAGE_UP
- The user has activated the page up
area of a scroll bar.
- Since:
JDK1.0
SHIFT_MASK
public static final int SHIFT_MASK
- This flag indicates that the Shift key was down when the event
occurred.
- Since:
JDK1.0
TAB
public static final int TAB
- The Tab key.
- Since:
JDK1.0
UP
public static final int UP
- The Up Arrow key, a non-ASCII action key.
- Since:
JDK1.0
WINDOW_DEICONIFY
public static final int WINDOW_DEICONIFY
- The user has asked the window manager to de-iconify the window.
- Since:
JDK1.0
WINDOW_DESTROY
public static final int WINDOW_DESTROY
- The user has asked the window manager to kill the window.
- Since:
JDK1.0
WINDOW_EXPOSE
public static final int WINDOW_EXPOSE
- The user has asked the window manager to expose the window.
- Since:
JDK1.0
WINDOW_ICONIFY
public static final int WINDOW_ICONIFY
- The user has asked the window manager to iconify the window.
- Since:
JDK1.0
WINDOW_MOVED
public static final int WINDOW_MOVED
- The user has asked the window manager to move the window.
- Since:
JDK1.0
arg
public java.lang.Object arg
- An arbitrary argument of the event. The value of this field
depends on the type of event.
- Since:
JDK1.0
clickCount
public int clickCount
- For
MOUSE_DOWN
events, this field indicates the
number of consecutive clicks. For other events, its value is
0
.
- Since:
JDK1.0
evt
public java.awt.Event evt
- The next event. This field is set when putting events into a
linked list.
- Since:
JDK1.0
id
public int id
- Indicates which type of event the event is, and which
other
Event
variables are relevant for the event.
- Since:
JDK1.0
key
public int key
- The key code of the key that was pressed in a keyboard event.
- Since:
JDK1.0
modifiers
public int modifiers
- The state of the modifier keys.
NOTE: changing the modifier keys is not recommended, because many
native implementations do not recognize modifier changes. This is
especially true when the shift modifier is changed.
- Since:
JDK1.0
target
public java.lang.Object target
- The target component. This indicates the component over which the
event occurred or with which the event is associated.
- Since:
JDK1.0
when
public long when
- The time stamp.
- Since:
JDK1.0
x
public int x
- The x coordinate of the event.
- Since:
JDK1.0
y
public int y
- The y coordinate of the event.
- Since:
JDK1.0
Event
public Event(Object target,
long when,
int id,
int x,
int y,
int key,
int modifiers,
Object arg)
- Creates an instance of
Event
with the specified target
component, time stamp, event type, x and y
coordinates, keyboard key, state of the modifier keys, and
argument.
- Parameters:
- target - the target component.
- when - the time stamp.
- id - the event type.
- x - the x coordinate.
- y - the y coordinate.
- key - the key pressed in a keyboard event.
- modifiers - the state of the modifier keys.
- arg - the specified argument.
- Since:
- JDK1.0
Event
public Event(Object target,
long when,
int id,
int x,
int y,
int key,
int modifiers)
- Creates an instance of
Event
, with the specified target
component, time stamp, event type, x and y
coordinates, keyboard key, state of the modifier keys, and an
argument set to null
.
- Parameters:
- target - the target component.
- when - the time stamp.
- id - the event type.
- x - the x coordinate.
- y - the y coordinate.
- key - the key pressed in a keyboard event.
- modifiers - the state of the modifier keys.
- Since:
- JDK1.0
Event
public Event(Object target,
int id,
Object arg)
- Creates an instance of
Event
with the specified
target component, event type, and argument.
- Parameters:
- target - the target component.
- id - the event type.
- arg - the specified argument.
- Since:
- JDK1.0
controlDown
public boolean controlDown()
- Checks if the Control key is down.
- Returns:
-
true
if the key is down;
false
otherwise.
- Since:
- JDK1.0
- See Also:
- modifiers, shiftDown, metaDown
metaDown
public boolean metaDown()
- Checks if the Meta key is down.
- Returns:
-
true
if the key is down;
false
otherwise.
- Since:
- JDK1.0
- See Also:
- modifiers, shiftDown, controlDown
paramString
protected java.lang.String paramString()
- Returns the parameter string representing this event.
This string is useful for debugging.
- Returns:
- the parameter string of this event.
- Since:
- JDK1.0
shiftDown
public boolean shiftDown()
- Checks if the Shift key is down.
- Returns:
-
true
if the key is down;
false
otherwise.
- Since:
- JDK1.0
- See Also:
- modifiers, controlDown, metaDown
toString
public java.lang.String toString()
- Returns a representation of this event's values as a string.
- Returns:
- a string that represents the event and the values
of its member fields.
- Overrides:
- toString in class Object
- Since:
- JDK1.1
- See Also:
- paramString
translate
public void translate(int x,
int y)
- Translates this event so that its x and y
coordinates are increased by dx and dy,
respectively.
This method translates an event relative to the given component.
This involves, at a minimum, translating the coordinates into the
local coordinate system of the given component. It may also involve
translating a region in the case of an expose event.
- Parameters:
- dx - the distance to translate the x coordinate.
- dy - the distance to translate the y coordinate.
- Since:
- JDK1.0
All Packages Class Hierarchy This Package Previous Next Index